<?php

require_once PHP_UI_PATH . DS . 'UIControl.php';
require_once PHP_UI_PATH . DS . 'DataSet.php';

class Checkbox extends UIControl implements DataSet {

    private $options = array();

    public function getOptions() {
        return $this->options;
    }

    public function setOptions(array $options) {
        $this->options = $options;
    }

    protected function getControlRendering() {
        $options = $this->getOptions();
        $render = "";
        $i = 0;
        foreach ($options as $option) {
            $i++;
            $render .= "
                <input type='checkbox' name='Values[{$this->getName()}][]' class='{$this->getStyleClasses()}' value='$option' id='{$this->getId()}_{$i}' />
                <label for='{$this->getId()}_{$i}'>$option</label>";
        }

        return $render;
    }

    protected function getScriptRendering() {
        return parent::getScriptRendering();
    }

}

?>
